﻿@namespace ERP.Blazor
@using AntDesign
@using AntDesign.ProLayout
@using System.Threading

@inherits AntProComponentBase
@inject IOptions<ProSettings> ProSettings

@inject IJSRuntime IJSRuntime;
@inject NavigationManager NavigationManager

<div class="naviatiotabs" style="@_style">
    <ERP.Abp.AntDesignUI.ReuseTabs Id="custom-nav" />
</div>
@*
@if (ProSettings.Value.FixedHeader) {
   <div style="height:40px"></div>
}
*@
@code
{
    private string BandStyle;
    protected override async void OnInitialized()
    {
        base.OnInitialized();
        await SetStyle();
    }
    private string _style { get; set; }
    private string _blankStyle { get; set; }
    private async Task SetStyle()
    {
        _style = ClassMapper.Clear()
            .If(";padding:1px 5px 5px 5px;z-index:10; width:calc(100% - 10px) ", () => true)
            .ToString();
        _blankStyle = $"height:{ProSettings.Value.FixedHeader}px";
        await OnThemeChange();
    }
    protected override async Task OnInitializedAsync()
    {
        await base.OnInitializedAsync();
        await SetStyle();
    }
    private async Task OnThemeChange()
    {
        await Task.Run(async () =>
         {
             await Task.Delay(200);
             var bg = await IJSRuntime.InvokeAsync<string>("dom.getStyle", ".ant-layout", "backgroundColor");
             Console.WriteLine(bg);
             await IJSRuntime.InvokeVoidAsync("dom.css", "#ApplicationContainer .naviatiotabs .ant-tabs-nav", new { background = bg });
         });
    }

    protected override async void OnStateChanged()
    {
        await SetStyle();
    }
}

